<template>
  <div class="time-line-container">
    <ol class="time-line-list" v-if="!$common.isEmpty(timeLineList)">
      <li class="time-line-li"
          v-for="(timeLine, index) in timeLineList"
          :key="index">
        <div class="time-line-content"
             :class="{ leftTimeLine: index % 2 === 0 && !$common.mobile(), rightTimeLine: index % 2 !== 0 || $common.mobile() }">
          <el-avatar shape="square" class="avatar-img" :size="36"
                     :src="avatar"></el-avatar>
          <div class="time-line-box"
               :style="{background: $constant.time_line_color[index % $constant.time_line_color.length]}">
            <div class="box-tag" v-if="index % 2 === 0 && !$common.mobile()"
                 :style="{'border-color': 'transparent transparent transparent '+$constant.time_line_color[index % $constant.time_line_color.length]}"></div>
            <div class="box-tag" v-if="index % 2 !== 0 || $common.mobile()"
                 :style="{'border-color': 'transparent '+$constant.time_line_color[index % $constant.time_line_color.length]+' transparent transparent'}"></div>
            <div class="my-content" v-html="timeLine.content"></div>
            <div style="display: flex;justify-content: space-between">
              <div>😃 {{ timeLine.createTime }}</div>
            </div>
          </div>
        </div>
      </li>
    </ol>
    <div class="time-line-go">
      <i class="fa fa-paper-plane" @click="launch()"></i>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    timeLineList: {
      type: Array
    },
    avatar: {
      type: String
    }
  },

  data() {
    return {}
  },

  computed: {},

  watch: {},

  created() {

  },

  mounted() {

  },

  methods: {
    launch() {
      this.$emit("launch");
    }
  }
}
</script>

<style scoped>

.time-line-container {
  padding: 20px;
  margin: 0 auto;
}

.time-line-list {
  padding: 100px 0 20px;
  margin: 0;
  position: relative;
  list-style: none;
}

.time-line-list:before {
  content: '';
  width: 4px;
  border-radius: 50%;
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--themeBackground);
}

.time-line-list:after {
  content: '';
  width: 12px;
  height: 12px;
  border: 4px solid var(--maxLightRed);
  border-radius: 50%;
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background-color: var(--white);
  animation: weiYanShadowFlashing 1.5s linear infinite;
}

.time-line-li {
  margin: 5px auto;
}

.time-line-content {
  position: relative;
  width: 50%;
}

.leftTimeLine {
  text-align: right;
}

.rightTimeLine {
  margin-left: 50%;
}

.time-line-content:before {
  content: '';
  width: 12px;
  height: 12px;
  border: 4px solid var(--blue);
  border-radius: 50%;
  position: absolute;
  top: 10px;
  background-color: var(--white);
}

.leftTimeLine:before {
  right: 0;
  transform: translateX(10px);
}

.rightTimeLine:before {
  left: 0;
  transform: translateX(-10px);
}

.avatar-img {
  position: absolute;
  top: 0;
  transition: all 0.3s ease-in-out;
}

.leftTimeLine .avatar-img {
  right: 25px;
}

.rightTimeLine .avatar-img {
  left: 25px;
}

.time-line-box {
  font-size: 16px;
  padding: 10px;
  width: 360px;
  border-radius: 5px;
  position: relative;
  letter-spacing: 0.1em;
  font-weight: 400;
  transition: all 0.3s ease-in-out;
  color: var(--black);
  text-align: left;
  display: inline-block;
}

.leftTimeLine .time-line-box {
  margin-right: 90px;
}

.rightTimeLine .time-line-box {
  margin-left: 90px;
}

.time-line-box:hover, .avatar-img:hover {
  transform: translateY(-5px);
  box-shadow: 0 0 16px 3px var(--miniMask);
}

.box-tag {
  content: '';
  position: absolute;
  border-style: solid;
}

.leftTimeLine .box-tag {
  right: -10px;
  border-width: 15px 0 5px 10px;
}

.rightTimeLine .box-tag {
  left: -10px;
  border-width: 15px 10px 5px 0;
}

.my-content {
  margin: 0 10px 10px;
  line-height: 30px;
}

.time-line-box > div:last-child {
  color: var(--greyFont);
  padding: 10px 10px 0;
  border-top: 1px dashed var(--white);
  font-size: 14px;
}

.time-line-go {
  color: var(--blue);
  font-weight: 700;
  font-size: 25px;
  margin: 20px auto;
  text-align: center;
}

.time-line-go i {
  cursor: pointer;
}

.time-line-go i:hover {
  animation: scale 1s linear infinite;
}

@media screen and (max-width: 1000px) {
  .time-line-box {
    width: calc(100% - 90px);
  }
}

@media screen and (max-width: 600px) {
  .time-line-content {
    margin-bottom: 50px;
  }

  .time-line-list:after {
    left: 0;
  }

  .time-line-list:before {
    left: 0;
  }

  .rightTimeLine {
    margin-left: unset;
  }

  .time-line-content {
    width: 100%;
  }
}
</style>
